package com.briup.product_source.controller;

import com.briup.product_source.pojo.ManagerBatch;
import com.briup.product_source.pojo.QuarantineRegistration;
import com.briup.product_source.result.Result;
import com.briup.product_source.service.ManagerBatchService;
import com.briup.product_source.service.QuarantineRegistrationService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "检疫登记模块")
@RestController
@RequestMapping("/quarantineRegistration")
public class QuarantineController {

    @Autowired
    private ManagerBatchService managerBatchService;

    @Autowired
    private QuarantineRegistrationService quarantineRegistrationService;

    @ApiOperation("分页展示接口")
    @GetMapping
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum",value = "当前页码", defaultValue = "1", required = true),
            @ApiImplicitParam(name = "pageSize",value = "每页大小", defaultValue = "10", required = true),
            @ApiImplicitParam(name = "grMechanism", value = "建议机构名称"),
            @ApiImplicitParam(name = "bQualified", value = "合格与否")
    })
    public Result queryAndPage(Integer pageNum, Integer pageSize, String grMechanism, String bQualified){
        PageInfo<QuarantineRegistration> pageInfo = quarantineRegistrationService.queryAndPage(pageNum,pageSize,grMechanism,bQualified);
        return Result.success(pageInfo);
    }

    @ApiOperation("新增或更新检疫记录接口")
    @PostMapping("/saveOrUpdate")
    public Result reviseRegistration(@RequestBody QuarantineRegistration qr) {
        quarantineRegistrationService.saveOrUpdate(qr);
        return Result.success();
    }


    @ApiOperation("删除功能接口")
    @DeleteMapping("/deleteById/{id}")
    public Result removeById(@PathVariable Integer id){
        quarantineRegistrationService.deleteByid(id);
        return Result.success();
    }


    @ApiOperation("批量删除接口")
    @DeleteMapping("/deleteByIdAll")
    public Result deleteByIdAll(@RequestBody List<Integer> ids){
        quarantineRegistrationService.deleteByIdAll(ids);
        return Result.success();
    }
}
